﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bank
{
    public class ClientCollections
    {

        public ClientCollections()
        {
            clients = new List<Client>();
        }

        public void listClients()
        {
            foreach (Client client in clients)
            {
                client.showClientInformation();
            }
        }
            
        public int addClient(Client client)
        {
            clients.Add(client);          
            return 0;
        }

        public Client addClient(String firstName, String lastName,String pesel)
        {
            Client newClient = new Client();
            newClient.FirstName = firstName;
            newClient.LastName = lastName;
            newClient.Pesel = pesel;
            newClient.ClientID = (Int32) getUnOccupiedID();
            clients.Add(newClient);
            return newClient;
        }

        public int removeClient(Int32 clientID)
        {
            foreach (Client c in clients)
            {
                if (c.ClientID == clientID)
                    clients.Remove(c);
            }
            return 0;
        }


        public int removeClient(String pesel)
        {
            foreach (Client c in clients)
            {
                if (c.Pesel == pesel)
                    clients.Remove(c);
            }
            return 0;
        }

        public Client getClient(Int32 clientID)
        {
            Client client = null;           
            foreach (Client c in clients)
            {
                if (c.ClientID == clientID)
                {
                    client = c;                    
                }
            }
            return client;
        }

        public Client getClient(String pesel)
        {
            Client client  = null;          
            foreach (Client c in clients)
            {
                if (c.Pesel == pesel )
                {
                    client = c;                    
                }                
            }
            return client;
        }

        public static long getUnOccupiedID()
        {
            counterID += 1;
            return counterID;
        }

        private static List<Client> clients;
        public static List<Client> ClientsList
        {
            get { return clients; }
        }

        private static long counterID = 0;

    }
}
